home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************
- * *
- * SktSocketUser.h *
- * Copyright 1992 by Nik A Gervae *
- * *
- * One of a set of three Objective-C classes (SktSocketManager, SktSocket, *
- * and SktSocketUser) which implement a convenient interface to Berkeley *
- * stream sockets under NeXTSTEP(r). See the accompanying class *
- * specifications (files with a .rtf or .spec suffix) for further *
- * information. *
- * *
- * NeXTSTEP is a registered trademark of NeXT Computer, Inc. *
- * *
- ****************************************************************************
- * *
- * LICENSE *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation. *
- * *
- * The program and this makefile are distributed in the hope that it will *
- * be useful, but are provided "AS IS" AND WITHOUT ANY WARRANTY; without *
- * any express or implied warranty of MERCHANTABILITY or FITNESS FOR A *
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. *
- * Any use or distribution of the program and documentation must include *
- * appropriate copyrights to acknowledge Nik A. Gervae and the Free *
- * Software Foundation, Inc. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
- * *
- ****************************************************************************
- * *
- * VERSION HISTORY *
- * *
- * Version numbers are simply dates in the form YYYYMMDD. These represent *
- * the date that version was finished. Only significantly changed versions *
- * are reported here, or those versions requiring explanation of changes. *
- * There may be many interim stages between dated versions. *
- * *
- * DateVersion Primary Author Notes *
- * ----------- --------------- -------------------------------------------- *
- * 19920327 Nik A Gervae First released version *
- * 19920723 Nik A Gervae Actually released *
- * *
- ***************************************************************************/
-
- #ifdef NS3
- #import <objc/zone.h>
- #else
- #import <zone.h>
- #endif
-
- #import <objc/Object.h>
-
- #import "SktSocket.h"
- #import "util.h"
-
- /*
- * INQSIZE is the minimum size of a queue buffer.
- * It should be at least twice the observed maximum
- * length of a normal input line (which is usually
- * less than a terminal's width, 80 chars or so).
- */
- #define INQSIZE 512
-
- /***************************************************************************
- * *
- * SktSocketUser class *
- * *
- * The instance variables socket, doesStrip, doesStripCRLF, and delimiter *
- * are accessed only through methods (except in -initWithSocket: and *
- * -free), so that you can override the behavior in subclasses by returning *
- * specific values. You could have a subclass that always strips by *
- * overriding -doesStrip to always return YES, for example. It may sound *
- * gratuitous now, but the habit *will* pay off sooner or later. *
- * *
- ***************************************************************************/
- @interface SktSocketUser : Object
- {
- struct SktSocket *socket; // SktSocket object handling actual I/O
-
- BOOL doesStrip; // whether to strip delimiter from input
- BOOL doesStripCRLF; // whether to strip any CR or LF from input
-
- char delimiter; // delimiter for lines; defaults to '\n'
- char *inputQueue; // text waiting to be processed
- long int queueLength; // # chars in queue
- long int queueLimit; // if >0, max # of lines allowed in queue
-
- NXZone *zone; // zone alloc'ed from
- }
-
-
- // Initializing
- - initWithSocket:(struct SktSocket *)aSocket;
- - init;
- - free;
-
- - setDelimiter:(char)aChar;
- - (char)delimiter;
- - setdoesStrip:(BOOL)flag;
- - (BOOL)doesStrip;
- - setDoesStripCRLF:(BOOL)flag;
- - (BOOL)doesStripCRLF;
- - setQueueLimit:(long int)limit;
- - (long int)queueLimit;
-
- // Access methods
-
- - (struct SktSocket *)setSocket:(struct SktSocket *)aSocket;
- - (struct SktSocket *)socket;
-
- // I/O processing
-
- - queueInput:(const char *)input ofLength:(long int)length;
- - purgeInput;
-
- - queueOutput:(const char *)output ofLength:(long int)length;
- - queueOutputString:(const char *)aString;
-
- - (long int)queueLength;
- - (long int)getInput:(char *)input ofLength:(long int)length orLess:(BOOL)flag;
- - ungetInput:(char *)input ofLength:(long int)length;
- - (long int)getAllInput:(char **)input;
-
- - (char *)inputToChar:(char)aChar;
- - (char *)inputToChar:(char)aChar inZone:(NXZone *)aZone;
-
- - (char *)nextInputLine;
- - (char *)nextInputLineInZone:(NXZone *)aZone;
-
- @end /*interface SktSocketUser*/